function point = threeball(r1,r2,r3)
%求解三球交点
x_off=0;
y_off=0;
z_off=0;
%1\2\3对应的是0、1、3
x1=x_off-0.66;
y1=y_off+0.52;
z1=z_off;
x2=x_off+0.4;
y2=y_off+0.52;
z2=z_off+0.5;
x3=x_off+0.4;
y3=y_off-0.54;
z3=z_off;

A1=r1^2-x1^2-y1^2-z1^2;
A2=r2^2-x2^2-y2^2-z2^2;
A3=r3^2-x3^2-y3^2-z3^2;
A21=-(A2-A1)/2;
A31=-(A3-A1)/2;

X21=x2-x1;
X31=x3-x1;
Y21=y2-y1;
Y31=y3-y1;
Z21=z2-z1;
Z31=z3-z1;
D=X21*Y31-Y21*X31;

B0=(A21*Y31-A31*Y21)/D;
B1=(Y21*Z31-Y31*Z21)/D;
C0=(A31*X21-A21*X31)/D;
C1=(X31*Z21-X21*Z31)/D;

E=B1^2+C1^2+1;
F=B1*(B0-x1)+C1*(C0-y1)-z1;
G=(B0-x1)^2+(C0-y1)^2+z1^2-r1^2;

point(3,1)=(-F+(F^2-E*G)^(1/2))/E; %就这个东西，它有时候会算出来复数
if ~isreal(point(3,1))
    point(3,1)=0;
end
point(1,1)=B0+B1*point(3);
point(2,1)=C0+C1*point(3);
end

